.class Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;
.super Ljava/lang/Object;
.source "SerialBuffer.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/felhr/usbserial/SerialBuffer;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x2
    name = "SynchronizedBuffer"
.end annotation


# instance fields
.field private buffer:[B

.field private position:I

.field final synthetic this$0:Lcom/felhr/usbserial/SerialBuffer;


# direct methods
.method public constructor <init>(Lcom/felhr/usbserial/SerialBuffer;)V
    .locals 0

    .line 114
    iput-object p1, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->this$0:Lcom/felhr/usbserial/SerialBuffer;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/16 p1, 0x4000

    .line 115
    new-array p1, p1, [B

    iput-object p1, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->buffer:[B

    const/4 p1, -0x1

    .line 116
    iput p1, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I

    return-void
.end method


# virtual methods
.method public declared-synchronized get()[B
    .locals 4

    monitor-enter p0

    .line 142
    :try_start_0
    iget v0, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    const/4 v1, -0x1

    if-ne v0, v1, :cond_0

    .line 146
    :try_start_1
    invoke-virtual {p0}, Ljava/lang/Object;->wait()V
    :try_end_1
    .catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    :catch_0
    move-exception v0

    .line 149
    :try_start_2
    invoke-virtual {v0}, Ljava/lang/InterruptedException;->printStackTrace()V

    .line 152
    :cond_0
    :goto_0
    iget v0, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I

    const/4 v2, 0x0

    if-gt v0, v1, :cond_1

    new-array v0, v2, [B
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    monitor-exit p0

    return-object v0

    .line 153
    :cond_1
    :try_start_3
    iget-object v0, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->buffer:[B

    iget v3, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I

    invoke-static {v0, v2, v3}, Ljava/util/Arrays;->copyOfRange([BII)[B

    move-result-object v0

    .line 154
    iget-object v2, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->this$0:Lcom/felhr/usbserial/SerialBuffer;

    invoke-static {v2}, Lcom/felhr/usbserial/SerialBuffer;->access$000(Lcom/felhr/usbserial/SerialBuffer;)Z

    move-result v2

    if-eqz v2, :cond_2

    const/4 v2, 0x1

    .line 155
    invoke-static {v0, v2}, Lcom/felhr/usbserial/UsbSerialDebugger;->printLogGet([BZ)V

    .line 156
    :cond_2
    iput v1, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I
    :try_end_3
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 157
    monitor-exit p0

    return-object v0

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public declared-synchronized reset()V
    .locals 1

    monitor-enter p0

    const/4 v0, -0x1

    .line 162
    :try_start_0
    iput v0, p0, Lcom/felhr/usbserial/SerialBuffer$SynchronizedBuffer;->position:I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 163
    monitor-exit p0

    return-void

    :catchall_0
    move-exception v0

    monitor-exit p0

    throw v0
.end method
